﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;
using TSVNAddin.Config;

namespace TSVNAddinUtils.Test
{
	[TestFixture]
	public class MakeConfigCommandFixture
	{
		[Test]
		public void Exec()
		{
			string keyName = @"SOFTWARE\TortoiseSVN";
			string tMergePath = @"c:\TMerge.exe";
			string procPath = @"c:\Proc.exe";

			var registry = MockRepository.GenerateStub<RegistryAdapter>();
			registry.Expect(x => x.GetValue(keyName, "TMergePath")).Return(tMergePath);
			registry.Expect(x => x.GetValue(keyName, "ProcPath")).Return(procPath);

			var configStorage = MockRepository.GenerateMock<ConfigStorage>((XmlFileStorage)null);
			configStorage.Expect(x => x.StoreAddinConfig(null)).IgnoreArguments().WhenCalled(invocation =>
				{
					AddinConfig config = (AddinConfig)invocation.Arguments[0];
					Assert.AreEqual(config.TMergePath, tMergePath);
					Assert.AreEqual(config.ProcPath, procPath);
				}

			);

			var command = new MakeConfigCommand(registry, configStorage);
			command.Exec(new string[0]);

			configStorage.VerifyAllExpectations();
		}
	}
}
